﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KSATouch
{
    /// <summary>
    /// This class encapsulates the main touch events including move, down, and up. For each it passes all available contact information
    /// </summary>
    public class ContactEventArgs
    {
        private Contact contact;

        public Contact Contact
        {
            get { return contact; }
            set { contact = value; }
        }


        /// <summary>
        /// Handles Contact information
        /// </summary>
        /// <param name="contact"></param>
        public ContactEventArgs(Contact contact)
        {
            this.contact = contact;
        }
    }

    /// <summary>
    /// Event arguments to get the current contacts currently available..including hovering, touch, and objects
    /// </summary>
    public class FrameReadyEventArgs
    {
        private List<Contact> hoveringContacts;

        public List<Contact> HoveringContacts
        {
            get { return hoveringContacts; }
            set { hoveringContacts = value; }
        }

        private List<Contact> currentContacts;

        public List<Contact> CurrentContacts
        {
            get { return currentContacts; }
            set { currentContacts = value; }
        }
    }
    public delegate void ContactDownEventHandler(object sender, ContactEventArgs e);
    public delegate void ContactUpEventHandler(object sender, ContactEventArgs e);
    public delegate void ContactMovedEventHandler(object sender, ContactEventArgs e);
    public delegate void FrameReadyEventHandler(object Sender, FrameReadyEventArgs e);
    public delegate void OrderRecievedEventHandler(string Order);



    /// <summary>
    /// This part of the class is meant to encapsulate events such as Down, Up, Moved/Changed for the contacts.  
    /// </summary>
    public partial class KSATouch
    {
        public event FrameReadyEventHandler FrameReady;
        public virtual void OnFrameReady(FrameReadyEventArgs e)
        {
            if (FrameReady != null)
            {
                FrameReady(this, e);
            }
        }

        #region touch events
        public event ContactDownEventHandler ContactDown;
        public virtual void OnContactDown(ContactEventArgs e)
        {
            if (ContactDown != null)
            {
                ContactDown(this, e);
            }
        }

        public event ContactUpEventHandler ContactUp;
        public virtual void OnContactUp(ContactEventArgs e)
        {
            if (ContactUp != null)
            {
                ContactUp(this, e);
            }
        }

        public event ContactMovedEventHandler ContactChanged;
        public virtual void OnContactChanged(ContactEventArgs e)
        {
            if (ContactChanged != null)
            {
                ContactChanged(this, e);
            }
        }
        #endregion


        /// <summary>
        /// the following event fires when a voice command is recieved
        /// </summary>
        public event OrderRecievedEventHandler OrderRecieved;
        public virtual void OnOrderRecieved(string order)
        {
            if (OrderRecieved != null)
            {
                OrderRecieved(order);
            }
        }

    }
}
